<template>
  <div class="app-container">
    <el-table  :data="list">
      <el-table-column label="ID" align="center" prop="registrationId" />
      <!-- <el-table-column label="患者ID" align="center" prop="patientId" />
      <el-table-column label="医生ID" align="center" prop="physicianId" />
      <el-table-column label="操作员ID" align="center" prop="operatorId" /> -->
      <!-- <el-table-column label="诊所ID" align="center" prop="companyId" />
      <el-table-column label="科室ID" align="center" prop="departmentId" /> -->
      <el-table-column label="挂号费用ID" align="center" width="150" prop="registeredfeeId" />
      <el-table-column label="挂号总金额" align="center" width="150" prop="registrationAmount" />
      <el-table-column label="挂号编号" align="center" width="150" prop="registrationNumber" />
      <el-table-column label="挂号状态" align="center" width="150" prop="registrationStatus" />
      <!-- <el-table-column label="排班主表ID" align="center" prop="schedulingId" />
      <el-table-column label="排班时段表ID" align="center" prop="schedulingSubsectionId" />
      <el-table-column label="排班星期表ID" align="center" prop="schedulingWeekId" /> -->
      <el-table-column label="创建时间" align="center" width="150" prop="createTime" />
      <el-table-column label="更新时间" align="center" width="150" prop="updateTime" />
      <!-- <el-table-column label="收费总表id" align="center" prop="pkgId" /> -->
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total=total>
    </el-pagination>
  </div>
</template>

<script>
import { queryregtion } from "@/api/dzmorder";

export default {
  // visit    
  name: "visit",
  data() {
    return{
        // 分页后的当前页数据
        list: [],
        //当前数据页的第几页
        currentPage: 1,
        // 总数据条数
        total: 0,
        // 每页显示多少行数据,默认为10条
        pagesize: 10,
        // 代表是从后端获取的所有数据
        ticket: []
    }
  },
  created() {
        this.getDoctors();
  },
  methods: {
    /** 用于查询就诊李列表 */
    getDoctors() {
          //this.listLoading = true;
         queryregtion().then(response => {
            console.log(response.data[0]);
            if(response.code === 200){
                this.ticket = response.data;
                //获取返回数据的总行数
                this.total = response.data.length;
                // 获取当前页的数据,此方法在下方定义
                this.getDoctorInfo()
                this.$message({
                    message: '数据加载成功',
                    type: 'success'
                })
            } else {
                // 失败提示信息
                this.$$message({
                    message: '数据加载错误',
                    type: 'error'
                })
            }
         });
    },
    // 此方法用来获取当前页的数据
    getDoctorInfo(){
        // 清空表格的list 数据
        this.list=[];
        // 获取当前页的数据
        for(
            let i = (this.currentPage - 1) * this.pagesize;
            i < this.total;
            i++
        ){
            // 将便利的数据添加到 list 里面
            this.list.push(this.ticket[i]);
            // 判断是否达到每一页的要求
            if(this.list.length === this.pagesize)
            break;
        }
    },
    // 分页时修改每页的行数,这里会自动传入一个size
    handleSizeChange(size) {
        // 修改当前每页的数据行数
        this.pagesize = size;
        // 数据重新分页
        this.getDoctorInfo();
    },
    // 调整当前的页码
      handleCurrentChange(pageNumber) {
          // 修改当前的页码
        this.currentPage = pageNumber;
        //数据重新分页
        this.getDoctorInfo();
    }
  }
};
</script>